function out = g2400 % Keithley Instruments Inc. March 4, 2003 % This program is generated using Intrument Creation Tool from % Instrument Control Toolbox v2.2 Matlab 6.5 (R13) % Set up for CEC GPIB card with Keithley Model 2400 source Meter % If you have a different GPIB card, use the instrument creation tool % to generate the first portion of the code. % You can then copy Model 2400 Specific Functions into your mfile. % or you may just try to change the GPIB maufacturer name in the GPIB % object. % Create the instrument object. obj1 = gpib('CEC', 0, 24); % Set the property values. set(obj1, 'BoardIndex', 0); set(obj1, 'ByteOrder', 'littleEndian'); set(obj1, 'BytesAvailableFcn', ''); set(obj1, 'BytesAvailableFcnCount', 48); set(obj1, 'BytesAvailableFcnMode', 'eosCharCode'); set(obj1, 'CompareBits', 8); set(obj1, 'EOIMode', 'on'); set(obj1, 'EOSCharCode', 'LF'); set(obj1, 'EOSMode', 'read&write'); set(obj1, 'ErrorFcn', ''); set(obj1, 'InputBufferSize', 2000); set(obj1, 'Name', 'GPIB0-24'); set(obj1, 'OutputBufferSize', 2000); set(obj1, 'OutputEmptyFcn', ''); set(obj1, 'PrimaryAddress', 24); set(obj1, 'RecordDetail', 'compact'); set(obj1, 'RecordMode', 'overwrite'); set(obj1, 'RecordName', 'record.txt'); set(obj1, 'SecondaryAddress', 0); set(obj1, 'Tag', ''); set(obj1, 'Timeout', 10); set(obj1, 'TimerFcn', ''); set(obj1, 'TimerPeriod', 1); set(obj1, 'UserData', []); if nargout > 0 out = [obj1]; end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Model 2400 Specific Functions % Sweep current and measure back voltage fopen(obj1) fprintf(obj1,':*RST') % setup the 2400 to generate an SRQ on buffer full fprintf(obj1,':*ESE 0') fprintf(obj1,':*CLS') fprintf(obj1,':STAT:MEAS:ENAB 512') fprintf(obj1,':*SRE 1') % buffer set up fprintf(obj1,':TRAC:CLE') fprintf(obj1,':TRAC:POIN 10') % buffer size % Set up the Sweep fprintf(obj1,':SOUR:FUNC:MODE CURR') fprintf(obj1,':SOUR:CURR:STAR 0.0001') fprintf(obj1,':SOUR:CURR:STOP 0.001') fprintf(obj1,':SOUR:CURR:STEP 0.0001') fprintf(obj1,':SOUR:CLE:AUTO ON') fprintf(obj1,':SOUR:CURR:MODE SWE') fprintf(obj1,':SOUR:SWE:SPAC LIN') fprintf(obj1,':SOUR:DEL:AUTO OFF') fprintf(obj1,':SOUR:DEL 0') fprintf(obj1,':SENS:FUNC "VOLT"') fprintf(obj1,':SENS:FUNC:CONC ON') fprintf(obj1,':SENS:VOLT:RANG:AUTO OFF') %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % IMPORTANT: if the unit goes into compliance, % adjust the compliance or the range value fprintf(obj1,':SENS:VOLT:PROT:LEV 20') % voltage compliance fprintf(obj1,':SENS:VOLT:RANG 20') % volt measurement range %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% fprintf(obj1,':SENS:VOLT:NPLC 1') fprintf(obj1,':FORM:ELEM:SENS VOLT,CURR') fprintf(obj1,':TRIG:COUN 10') fprintf(obj1,':TRIG:DEL 0') fprintf(obj1,':SYST:AZER:STAT OFF') fprintf(obj1,':SYST:TIME:RES:AUTO ON') fprintf(obj1,':TRAC:TST:FORM ABS') fprintf(obj1,':TRAC:FEED:CONT NEXT') fprintf(obj1,':OUTP ON') fprintf(obj1,':INIT') % Used the serail poll function to wait for SRQ val = [1]; % 1st instrument in the gpib object, not the gpib add spoll(obj1,val); % keep control until SRQ fprintf(obj1,':TRAC:DATA?') A = scanstr(obj1,',','%f'); % parse the data & plot Curr=A(2:2:20,:) Volts=A(1:2:19,:) figure(1); plot(Curr,Volts,':bo','LineWidth',0.5,... 'MarkerEdgeColor','k',... 'MarkerFaceColor','r',... 'MarkerSize',5) xlabel('Source-current (A)'),ylabel('Measured-volts(V)') title('Keithley 2400: Sweeps I (0.1mA-1mA) & Measure V'); % reset all the registers & clean up % if the registers are not properly reset, % subsequent runs will not work! fprintf(obj1,'*RST') fprintf(obj1,':*CLS ') fprintf(obj1,':*SRE 0') % make sure STB bit is 0 STB = query(obj1, '*STB?'); fclose(obj1) delete(obj1) clear obj1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%